﻿using RSSNewsGrabberModule.Interfaces;

namespace RSSNewsGrabberModule.Mapping
{
    public class FieldInfo
    {
        public FieldInfo(FieldType type, string fieldName, IConverter converter)
        {
            Converter = converter;
            FieldName = fieldName;
            Type = type;
        }

        public FieldInfo(string type, string fieldName, IConverter converter)
        {
            Converter = converter;
            FieldName = fieldName;
            Type = ParseTypeString(type);
        }

        public string FieldName { get; private set; }

        public FieldType Type { get; private set; }

        public IConverter Converter { get; private set; }

        private FieldType ParseTypeString(string type)
        {
            switch (type)
            {
                case "single":
                    return FieldType.Single;
                case "multi":
                    return FieldType.Multi;
                default:
                    return FieldType.Undefined;
            }
        }
    }
}
